import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/*
*
*
* "我的"--通知设置
*
*
* */
class NotificationSettingsPage extends StatefulWidget {
  const NotificationSettingsPage({Key key}) : super(key: key);

  @override
  _NotificationSettingsPageState createState() =>
      _NotificationSettingsPageState();
}

class _NotificationSettingsPageState extends State<NotificationSettingsPage> {
  //未关注人私信
  bool noAttention = false;

  //我关注人及好友私信
  bool myFollow = false;

  //@我
  bool changeMy = false;

  //评论
  bool comment = false;

  //赞
  bool fabulous = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios, color: Colors.black),
          onPressed: () {
            ///界面返回
            Navigator.of(context).pop();
            print("返回");
          },
        ),
        backgroundColor: Colors.white,
        elevation: 1,
        title: Text(
          "通知设置",
          style: TextStyle(fontSize: 18, color: Color.fromRGBO(17, 17, 17, 1)),
        ),
      ),
      body: Column(
        children: <Widget>[
          //接收推送通知
          acceptPushNotification(),
          //私信通知title
          privateLetterNotice(),

          //未关注人私信
          noAttentions(),

          //我关注及好友私信
          focusOnPeople(),

          //互动通知
          interactiveNotification(),

          //@我
          myNotice(),

          //评论
          commentNotice(),

          //赞
          likeNotification(),
        ],
      ),
    );
  }

  ///推送消息通知
  Widget acceptPushNotification() {
    return GestureDetector(
      onTap: () {
        print("----------------接收推送通知-----------------");
      },
      child: Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(left: 16, right: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "接收推送通知",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Text(
              "未开启",
              style: TextStyle(
                  fontSize: 16, color: Color.fromRGBO(153, 153, 153, 1)),
            ),
            Container(
              margin: EdgeInsets.only(left: 12),
              child: Icon(
                Icons.arrow_forward_ios_sharp,
                size: 18,
                color: Color.fromRGBO(112, 112, 112, 1),
              ),
            )
          ],
        ),
      ),
    );
  }

  ///私信通知title
  Widget privateLetterNotice() {
    return Container(
      height: 32,
      margin: EdgeInsets.only(
        top: 12,
      ),
      width: MediaQuery.of(context).size.width - 32,
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  color: Color.fromRGBO(153, 153, 153, 0.2),
                  width: 1,
                  style: BorderStyle.solid))),
      child: Text(
        "私信通知",
        style: TextStyle(fontSize: 14, color: Color.fromRGBO(153, 153, 153, 1)),
      ),
    );
  }

  ///未关注人私信
  Widget noAttentions() {
    return Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(right: 16, left: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "未关注人私信",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Container(
              child: CupertinoSwitch(
                value: noAttention,
                activeColor: Color.fromRGBO(255, 64, 89, 1),
                onChanged: (value) {
                  setState(() {
                    noAttention = value;
                  });
                },
              ),
            ),
          ],
        ));
  }

  ///关注人私信
  Widget focusOnPeople() {
    return Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(right: 16, left: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "关注人私信",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Container(
              child: CupertinoSwitch(
                value: myFollow,
                //选中颜色
                activeColor: Color.fromRGBO(255, 64, 89, 1),
                onChanged: (value) {
                  setState(() {
                    myFollow = value;
                  });
                },
              ),
            ),
          ],
        ));
  }

  ///互动通知title
  Widget interactiveNotification() {
    return Container(
      height: 32,
      margin: EdgeInsets.only(top: 12),
      width: MediaQuery.of(context).size.width - 32,
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  color: Color.fromRGBO(153, 153, 153, 0.2),
                  width: 1,
                  style: BorderStyle.solid))),
      child: Text(
        "互动通知",
        style: TextStyle(fontSize: 14, color: Color.fromRGBO(153, 153, 153, 1)),
      ),
    );
  }

  ///@我
  Widget myNotice() {
    return Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(right: 16, left: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "@我",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Container(
              child: CupertinoSwitch(
                value: changeMy,
                activeColor: Color.fromRGBO(255, 64, 89, 1),
                onChanged: (value) {
                  setState(() {
                    changeMy = value;
                  });
                },
              ),
            ),
          ],
        ));
  }

  ///评论
  Widget commentNotice() {
    return Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(right: 16, left: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "评论",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Container(
              child: CupertinoSwitch(
                value: comment,
                activeColor: Color.fromRGBO(255, 64, 89, 1),
                onChanged: (value) {
                  setState(() {
                    comment = value;
                  });
                },
              ),
            ),
          ],
        ));
  }

  ///赞
  Widget likeNotification() {
    return Container(
        height: 48,
        width: MediaQuery.of(context).size.width - 32,
        margin: EdgeInsets.only(right: 16, left: 16),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: Color.fromRGBO(153, 153, 153, 0.2),
                    width: 1,
                    style: BorderStyle.solid))),
        child: Row(
          children: <Widget>[
            Text(
              "赞",
              style:
                  TextStyle(fontSize: 16, color: Color.fromRGBO(17, 17, 17, 1)),
            ),
            Spacer(),
            Container(
              child: CupertinoSwitch(
                value: fabulous,
                activeColor: Color.fromRGBO(255, 64, 89, 1),
                onChanged: (value) {
                  setState(() {
                    fabulous = value;
                  });
                },
              ),
            ),
          ],
        ));
  }
}
